Definition

In this lesson, we'll look at the definition of synchronous microservices and get a quick introduction to an example.

Introduction#

This chapter deals with the technical options for implementing synchronous microservices. Chapter 6 already introduced the term “synchronous microservices”.

A microservice is synchronous if it makes a request to other microservices while processing requests and waits for the result.

The logic to handle a request in the microservice might not depend on the result of a request to a different microservice.

svg viewer
Synchronous Communication

The drawing above illustrates this kind of communication. While the left microservice processes a request, it calls the right microservice and waits for the result of this call.

Synchronous and asynchronous communication according to this definition are independent of the communication protocol.

Synchronous protocols#

A synchronous communication protocol means that a request returns a result.

For example, a REST or HTTP GET returns a result in an HTTP status, a JSON document, or an HTML page. If a system processes a REST request, makes a REST request itself to another system, and waits for the response, it is synchronous. Asynchronous REST systems were discussed in chapter 8.

Asynchronous protocols#

Asynchronous communication protocols, on the other hand, send messages to which the recipients react. There is no direct response.

Synchronous communication with an asynchronous protocol occurs when one system sends a message with an asynchronous communication protocol to another system and then waits to receive a response with an asynchronous communication protocol.

An example#

For example, a microservice for orders is synchronous if it calls a microservice for customer data while processing an order and waits for the customer data.

svg viewer
Architecture for a Synchronous System

The drawing above shows an exemplary synchronous architecture, which corresponds to the asynchronous architecture displayed in the third drawing within this lesson from chapter 6.

Here it is again for a refresher.

svg viewer
Architecture for an Asynchronous System

It describes an excerpt from an e-commerce system.

  • The microservices customer management, items, order, invoice, and delivery manage the respective data.
  • The catalog displays all information about the goods and considers the customer’s preferences.
  • Finally, the order process serves to order goods, issue the invoice, and deliver the goods.

The UI accesses catalog and order process and thus makes the processes implemented in these microservices available to the user. The UI can also display invoice and delivery data.

                                                 Q U I Z  

1

A microservice is synchronous if it ______.

A)

sends a request and does not wait on a response

B)

sends a request and waits on a response

C)

sends a request and does not wait on a response

Question 1 of 30 attempted

In the next lesson, we’ll continue studying details of the example introduced here.

Introduction
Example
Mark as Completed
Report an Issue